dw2elf: fix compilation errors — add dwarf.h, fix AT_name_a arg count#132
Merged
Conversation
- Add #include <dwarf.h> to get DW_TAG_compile_unit, DW_TAG_subprogram, DW_TAG_formal_parameter constants (not exported via libdwarfp.h alone) - Fix all dwarf_add_AT_name_a() calls: signature requires 4 args (die, name, Dwarf_P_Attribute *outattr, Dwarf_Error *error) not 3 https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
There was a problem hiding this comment.
Code Review
This pull request updates dw2elf.c to include the dwarf.h header and modifies dwarf_add_AT_name_a calls to include a mandatory Dwarf_P_Attribute parameter. Feedback was provided to ensure the return values of these calls are checked for errors to prevent incomplete DWARF generation.
| NULL, NULL, NULL, NULL, &cu_die, &err) != DW_DLV_OK) | ||
| return; | ||
| dwarf_add_AT_name_a(cu_die, (char *)srcname, &err); | ||
| dwarf_add_AT_name_a(cu_die, (char *)srcname, &attr_out, &err); |
There was a problem hiding this comment.
The return value of dwarf_add_AT_name_a is not checked. If this call fails, the compilation unit DIE will be created without a name, and the error state in err might be lost or cause issues in subsequent calls. It is recommended to check the return value for DW_DLV_OK, consistent with the error handling for dwarf_new_die_a and dwarf_add_die_to_debug_a.
if(dwarf_add_AT_name_a(cu_die, (char *)srcname, &attr_out, &err) != DW_DLV_OK)
return;| cu_die, NULL, NULL, NULL, | ||
| &func_die, &err) == DW_DLV_OK) | ||
| dwarf_add_AT_name_a(func_die, fname, &err); | ||
| dwarf_add_AT_name_a(func_die, fname, &attr_out, &err); |
| func_die, NULL, NULL, NULL, | ||
| ¶m_die, &err) == DW_DLV_OK) | ||
| dwarf_add_AT_name_a(param_die, pname, &err); | ||
| dwarf_add_AT_name_a(param_die, pname, &attr_out, &err); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs